package com.qianfeng.zhangwei.touchevent.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

/**
 * @说 明：
 * @项目名称：Sz1504Adv
 * @包 名： com.qianfeng.zhangwei.touchevent.adapter
 * @类 名： ViewPagerAdapter
 * @创 建人： zhangwei
 * @创建时间：2015-08-06 11:29
 * @版 本：v1.0
 * @修 改人：
 * @修改时间：
 * @修改备注：
 */
public class ViewPagerAdapter extends PagerAdapter {
    private List<View> views = new ArrayList<>();

    public ViewPagerAdapter(List<View> views) {
        this.views = views;
    }

    @Override
    public int getCount() {
        return views.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(views.get(position));
        return views.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(views.get(position));

    }
}
